package guard.song.com.guard;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.widget.TextView;

import java.util.HashSet;
import java.util.Set;

import cn.jpush.android.api.JPushInterface;
import guard.song.com.guard.service.MyService;

public class MainActivity extends AppCompatActivity {
    String msg = "Android : ";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        JPushInterface.setDebugMode(true);   // 设置调试模式
        JPushInterface.init(this);  //  开启JPush
        Log.d(msg, "The onCreate() event");
        //初始化sdk
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }
    // Method to start the service
    public void startService(View view) {
        startService(new Intent(getBaseContext(), MyService.class));
    }

    // Method to stop the service
    public void stopService(View view) {
        stopService(new Intent(getBaseContext(), MyService.class));
    }
    public void broadcastIntent(View view) {
        Intent intent = new Intent();
        intent.setAction("cn.jpush.android.intent.RECEIVE_MESSAGE");
        sendBroadcast(intent);
    }



    @Override
    protected void onStart() {
        super.onStart();
        Log.d(msg, "当活动即将可见时调用");
    }

    /** 当活动可见时调用 */
    @Override
    protected void onResume() {
        super.onResume();
        Log.d(msg, "当活动可见时调用");
    }

    /** 当其他活动获得焦点时调用 */
    @Override
    protected void onPause() {
        super.onPause();
        Log.d(msg, "当其他活动获得焦点时调用t");
    }

    /** 当活动不再可见时调用 */
    @Override
    protected void onStop() {
        super.onStop();
        Log.d(msg, "当活动不再可见时调用");
    }

    /** 当活动将被销毁时调用 */
    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(msg, "当活动将被销毁时调用");
    }
}
